#!/usr/bin/node

const log  = console.log,
      argv = process.argv[2];//如果命令行参数多于三个的话，因为这里获取的是第三个参数，则自动会忽略多余的参数

function help() {
  const msg = '' 
       + 'usage: cmd-name [OPTION] [expression]\n'
       + 'evaluate the expression.\n'
       + '\n'
       + 'Mandatory arguments to long options are mandatory for short options too.\n'
       + '  -h, --help output help information and exit\n';

  log(msg);

}


function calc(){
  try {
    log(`${argv}=${eval(argv)}`);
  } catch(e){
    log(`${argv} '不是合法的数学表达式！'`);
  }
}

if(typeof(argv)==='undefined' || argv==='--help' || argv==='-h'){
  help();
}else{
  calc();
}
